function initUserModel(sequelize, DataTypes) {
  const User = sequelize.define('User', {
    // 在这里定义模型属性
    userId: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey:true,
      autoIncrement: true // 开启自增
    },
    username: {
      type: DataTypes.STRING(50),
      allowNull: false,
    },
    password: {
      type: DataTypes.STRING(255),
      allowNull: false
    },
    email: {
      type: DataTypes.STRING(100),
      validate: {
        isEmail: true
      }
    },
    phone: {
      type: DataTypes.STRING(20),
      allowNull: true,
    },
    avatar: {
      type: DataTypes.STRING(255),
      allowNull: true,

    },
    role: {
      type: DataTypes.ENUM('admin', 'operator', 'customer_service'),
      defaultValue: 'operator'
    },
    status: {
      type: DataTypes.TINYINT,
      defaultValue: 1,
      comment: '1: normal, 2: disabled'
    }
  }, {
    tableName:'users',
  });
  return User;
}


module.exports = initUserModel;